<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!--有助于语音合成工具确定其所应该采用的发音，有助于翻译工具确定其翻译时所应遵守的规则-->
<html lang="zh-CN">
    <head>
        <%@include file="/WEB-INF/jsp/qsws/commons/head.jsp"%>
        <link rel="stylesheet" type="text/css" href="resources/qsws/css/sreach.css">
        <script src="resources/qsws/js/index.js" type="text/javascript"></script>
        <script type="text/javascript">
        	$(function(){
        		$('.sreach').click(function(){
        			window.location.href = 'qsws/toSearchResultPage?keyword=' + $('#wd').val();
        		});
        	});
        </script>
	</head>
	<body>
		<div class="wrap">
			<header class="clearfix">
                <div class="sreach_k l">
                	<a class="sreach"></a>
                	<input type="text" name="" id="wd" value="" placeholder="搜索课程或讲师"/>
                	<!--<ul id="ul1"></ul>-->
                </div>
                <a href="javascript:history.back();" class="cancel l" id="change">取消</a>
            </header>
            <div class="sect">
                <section>
                	<p>历史搜索</p>
                	<ul id="ul2"></ul>
                </section>
            </div>
		</div>
		 <!--JS放于body尾部-->
		<!-- <script src="resources/qsws/js/api.js"></script>
	    <script src="resources/qsws/js/template-native.js"></script> -->
        <script>
            var b =$('header').height();
            var a =$(window).height()-$('header').height()-$('footer').height();
            var arr = [];
            var inp = $('#wd');
            var change = $('#change');
//          $('.sect').height(a);
            $('.sect').css({'position':'absolute','top':b,'width':'100%','overflow-y':'scroll','overflow-x':'hidden'});
            
           	function search(){
           		 window.location.href='sousuolist.html'+'?id='+$('input').val();
               var str = $('input').val();
               
				if (sessionStorage.pagecount){
					sessionStorage.pagecount=Number(sessionStorage.pagecount) +1;
					if(sessionStorage.pagecount==6){sessionStorage.pagecount=1}
					}else{
						sessionStorage.pagecount=1;
					}
               	sessionStorage.setItem('msg'+[sessionStorage.pagecount], str);
           	}
            $('.sreach').click(function(){
                search();
            })  
    		var num1 = sessionStorage.pagecount
            for(var i=0;i<num1;i++){
            	var li = document.createElement('li');
	            var is = document.createElement('i');
	            var span = document.createElement('span');
	            is.innerHTML = i+1+'.';
	            span.innerHTML =  sessionStorage.getItem('msg'+(i+1));
	            span.className = 'hisy';
	            li.className = 'hisy_1';
	            // li.appendChild(is);
	            li.appendChild(span);
	            $('#ul2').append(li);
            }
            $('.hisy_1').click(function(){
            	$('#wd').val($(this).find('.hisy').html());
            	search();
            })
        </script>
        
        
	    <script>
	    	document.onkeydown=function(event){
				var e = event || window.event || arguments.callee.caller.arguments[0];
				if(e && e.keyCode==13){ // 按 回车 
			  		 search();
			    }
			 }; 
//	        function find(data) {
//	            var ul1 = document.getElementById('ul1');
//	            if (data.s.length) {
//	                ul1.style.display = 'block';
//	                var html = template('template1', data);
//	                document.getElementById('ul1').innerHTML = html;
//	            } else {
//	                ul1.style.display = 'none';
//	            }
//	        }
//	        window.onload = function() {
//	            var wd = document.getElementById('wd');
//	            var ul1 = document.getElementById('ul1');
//	            wd.onkeyup = function() {
//	                if (this.value != '') {
//	                    var script = document.createElement('script');
//	                    script.src = 'https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd='+this.value+'&cb=find';
//	                    document.body.appendChild(script);
//	                } else {
//	                    ul1.style.display = 'none';
//	                }
//	            }
//	        }
	    </script>
	</body>
</html>
